//
//  ScienceTechnologyCollectionViewCell.m
//  MansApp
//
//  Created by lanou3g on 15/7/13.
//  Copyright (c) 2015年 ACH. All rights reserved.
//

#import "ScienceTechnologyCollectionViewCell.h"

@implementation ScienceTechnologyCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _headImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, kP6Height(57), kP6width(375), kP6Height(250))];
        _headImageView.image = [UIImage imageNamed:@"cm2_btm_icn_account_prs@3x"];
        _headImageView.userInteractionEnabled = YES;
        _headImageView.contentMode = UIViewContentModeScaleAspectFill;
        /*
        UIViewContentModeScaleToFill,//压缩比例适应
        UIViewContentModeScaleAspectFit,// 按照高度缩放比例
        UIViewContentModeScaleAspectFill,//将上部多余截出
        UIViewContentModeRedraw,//压缩比例适应
        UIViewContentModeCenter,//显示中间部分
        UIViewContentModeTop,//显示上部
        UIViewContentModeBottom,//显示下部
        UIViewContentModeLeft,//显示左边
        UIViewContentModeRight,//显示右边
        UIViewContentModeTopLeft,
        UIViewContentModeTopRight,
        UIViewContentModeBottomLeft,
        UIViewContentModeBottomRight,
        */
        [self.contentView addSubview:_headImageView];
        _headLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, kP6Height(275), kP6width(365), kP6Height(20))];
        _headLabel.textColor = [UIColor whiteColor];
        _headLabel.shadowColor = [UIColor blackColor];
        _headLabel.textAlignment = NSTextAlignmentLeft;
        _headLabel.font = [UIFont systemFontOfSize:kP6Height(18) weight:1.5];
        [self.contentView  addSubview:_headLabel];
        
        UIView *itemView = [[UIView alloc] initWithFrame:CGRectMake(0, kP6Height(307), kP6width(375), kP6Height(603-307))];
        [self addSubview:itemView];
        for (int i = 0; i < 2; i++) {
            UIView *lineV = [[UIView alloc] initWithFrame:CGRectMake(10,kP6Height(603-307)/3*(i+1), kP6width(375)-20, 0.8)];
            lineV.backgroundColor = [UIColor grayColor];
            lineV.alpha = 0.5;
            [itemView addSubview:lineV];
        }
        UIView *lineH = [[UIView alloc] initWithFrame:CGRectMake(kP6width(375)/2, 0, 0.8, 2*kP6Height(603-307)/3)];
        lineH.backgroundColor = [UIColor grayColor];
        lineH.alpha = 0.5;
        [itemView addSubview:lineH];
        itemView.backgroundColor = [UIColor whiteColor];
        [self buttonWothItemView:itemView];
        [self labelWithItemView:itemView];
    }
    return self;
}


//加载 button
- (void)buttonWothItemView:(UIView *)itemView
{
    self.oneBut = [UIButton buttonWithType:UIButtonTypeCustom];
   [self buttonWithFrame:CGRectMake(5, 5, kP6width(375)/2-10, kP6Height(603-307)/3 -10) but:_oneBut addView:itemView];
    
    self.twoBut = [UIButton buttonWithType:UIButtonTypeCustom];
    [self buttonWithFrame:CGRectMake(kP6width(375)/2+5, 5, kP6width(375)/2-10, kP6Height(603-307)/3-10) but:_twoBut addView:itemView];
    
    self.threeBut = [UIButton buttonWithType:UIButtonTypeCustom];
    [self buttonWithFrame:CGRectMake(5, kP6Height(603-307)/3+5, kP6width(375)/2-10, kP6Height(603-307)/3-10) but:_threeBut addView:itemView];
    
    self.fourBut = [UIButton buttonWithType:UIButtonTypeCustom];
    [self buttonWithFrame:CGRectMake(kP6width(375)/2+5,kP6Height(603-307)/3+5, kP6width(375)/2-10, kP6Height(603-307)/3-10) but:_fourBut addView:itemView];
    
    self.fiverBut = [UIButton buttonWithType:UIButtonTypeCustom];
    [self buttonWithFrame:CGRectMake(5, 2*kP6Height(603-307)/3+5, kP6width(375)-10, kP6Height(603-307)/3-10) but:_fiverBut addView:itemView];
}

//加载 label
- (void)labelWithItemView:(UIView *)itemView
{
    _oneTitlelLable = [[UILabel alloc] initWithFrame:CGRectMake(10, 5, kP6width(375)/2-20, kP6Height(603-307)/3-kP6Height(55))];
    [self labelWithFont:kP6Height(17) lable:_oneTitlelLable addView:itemView];
    
    _twoTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(kP6width(375)/2+10, 5, kP6width(375)/2-20, kP6Height(603-307)/3-kP6Height(55))];
    [self labelWithFont:kP6Height(17) lable:_twoTitleLabel addView:itemView];
    _threeTitleLable = [[UILabel alloc] initWithFrame:CGRectMake(10, kP6Height(603-307)/3+5, kP6width(375)/2-20, kP6Height(603-307)/3-kP6Height(55))];
    [self labelWithFont:kP6Height(17) lable:_threeTitleLable addView:itemView];
    _fourTitleLable = [[UILabel alloc] initWithFrame:CGRectMake(kP6width(375)/2+10, kP6Height(603-307)/3+5, kP6width(375)/2-20, kP6Height(603-307)/3-kP6Height(55))];
    [self labelWithFont:kP6Height(17) lable:_fourTitleLable addView:itemView];
    
    _fiveTitleLable = [[UILabel alloc] initWithFrame:CGRectMake(10, 2*kP6Height(603-307)/3+5, kP6width(375)-20, kP6Height(603-307)/3-kP6Height(65))];
    [self labelWithFont:kP6Height(17) lable:_fiveTitleLable addView:itemView];
    
    _oneAuther_name = [[UILabel alloc] initWithFrame:CGRectMake(10, kP6Height(603-307)/3-kP6Height(50), kP6width(375)/2-20, kP6Height(20))];
    [self labelWithFont:kP6Height(12) lable:_oneAuther_name addView:itemView];
    _twoAuther_name = [[UILabel alloc] initWithFrame:CGRectMake(kP6width(375)/2+10, kP6Height(603-307)/3-kP6Height(50), kP6width(375)/2-20, kP6Height(20))];
    [self labelWithFont:kP6Height(12) lable:_twoAuther_name addView:itemView];
    _threeAuther_name = [[UILabel alloc] initWithFrame:CGRectMake(10, 2*kP6Height(603-307)/3-kP6Height(50), kP6width(375)/2-20, kP6Height(20))];
    [self labelWithFont:kP6Height(12) lable:_threeAuther_name addView:itemView];
    _fourAuther_name = [[UILabel alloc] initWithFrame:CGRectMake(kP6width(375)/2+10, 2*kP6Height(603-307)/3-kP6Height(50), kP6width(375)/2-20, kP6Height(20))];
    [self labelWithFont:kP6Height(12) lable:_fourAuther_name addView:itemView];
    _fiveAuther_name = [[UILabel alloc] initWithFrame:CGRectMake(10, 2*kP6Height(603-307)/3+kP6Height(603-307)/3-kP6Height(50), kP6width(375)/2-20, kP6Height(20))];
    [self labelWithFont:kP6Height(12) lable:_fiveAuther_name addView:itemView];
}

- (void)buttonWithFrame:(CGRect)frame but:(UIButton *)but addView:(UIView *)itemView
{
    but.frame = frame;
    [itemView addSubview:but];
//    but.backgroundColor = [UIColor cyanColor];
}

- (void)labelWithFont:(int)font lable:(UILabel *)label addView:(UIView *)addView
{
    label.textAlignment = NSTextAlignmentLeft;
    label.font = [UIFont systemFontOfSize:font];
    label.numberOfLines = 0;
    [addView addSubview:label];
}


@end
